package org.atlantis.datasink.codec;

import java.nio.ByteBuffer;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;

public class ByteEncoder implements IEncoder {

	@Override
	public ChannelBuffer encode(Channel channel, Object message) {
		if (message instanceof byte[]) return ChannelBuffers.wrappedBuffer((byte[]) message);
		if (message instanceof ByteBuffer) return ChannelBuffers.wrappedBuffer((ByteBuffer) message);
		return (ChannelBuffer) message;
	}
}
